﻿package mortal.game.view.copy.expCopy
{
    import Message.DB.Tables.*;
    import com.mui.containers.globalVariable.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import fl.data.*;
    import flash.display.*;
    import flash.geom.*;
    import frEngine.primitives.object2d.*;
    import mortal.component.window.*;
    import mortal.game.manager.*;
    import mortal.game.manager.window3d.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.scene3D.model.player.*;
    import mortal.game.scene3D.model.pools.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.groupCopy.view.*;
    import mortal.game.view.yyZiZuan.*;

    public class ExpCopyEnterWin extends GroupCopyBasePanel
    {
        private var _bg:GImageBitmap;
        private var _activeTypeBg:GImageBitmap;
        private var _rightPart:ExpCopyRightPart;
        private var _copyList:GTileList;
        private var _rewardList:GTileList;
        private var _img2d:Img2D;
        private var _rect3d:Rect3DObject;
        private var _effectPlayer1:EffectPlayer;
        private var _window:Window;

        public function ExpCopyEnterWin(param1:Window)
        {
            this._window = param1;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bg = UIFactory.gImageBitmap(ImagesConst.ExpCopyEnterBg, 0, 0, null, this.add2d);
            pushUIToDisposeVec(UIFactory.bg(336, 37, 531, 508, this, ImagesConst.ComboBg));
            pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.ExpCopyRightBg, 340, 40, this));
            this._activeTypeBg = UIFactory.gImageBitmap("", 400, 50, this);
            var _loc_1:* = ClockManager.instance.serverOpenDateNum;
            if (_loc_1 > 3)
            {
                this._activeTypeBg.imgUrl = "ExpCopyAcountTxt3.png";
                this._activeTypeBg.x = 580;
                this._activeTypeBg.y = 85;
                pushUIToDisposeVec(UIFactory.gImageBitmap("ExpCopyActiveTime.png", 550, 200, this));
            }
            else
            {
                this._activeTypeBg.imgUrl = "ExpCopyAcountTxt4.png";
                this._activeTypeBg.x = 580;
                this._activeTypeBg.y = 85;
            }
            this._rightPart = UICompomentPool.getUICompoment(ExpCopyRightPart);
            this._rightPart.move(340, 387);
            this.addChild(this._rightPart);
            this._rewardList = UIFactory.tileList(25, 432, 500, 80, this._window.contentTopOf3DSprite);
            this._rewardList.columnWidth = 40;
            this._rewardList.rowHeight = 40;
            this._rewardList.horizontalGap = 5;
            this._rewardList.verticalGap = 0;
            this._rewardList.setStyle("cellRenderer", YYZiZuanGiftCellRender);
            this._rewardList.direction = GBoxDirection.HORIZONTAL;
            this._rewardList.dataProvider = this.getGiftListDataProviderByCode(120100504);
            this._rewardList.drawNow();
            this._rewardList.x = (345 - this._rewardList.dataProvider.length * this._rewardList.columnWidth - (this._rewardList.dataProvider.length - 1) * this._rewardList.horizontalGap) * 0.5;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._bg.dispose(param1);
            this._bg = null;
            this._rightPart.dispose(param1);
            this._rightPart = null;
            this._activeTypeBg.dispose(param1);
            this._activeTypeBg = null;
            if (this._copyList)
            {
                this._copyList.dispose(param1);
                this._copyList = null;
            }
            this._rewardList.dispose(param1);
            this._rewardList = null;
            if (this._img2d)
            {
                this._img2d.dispose(param1);
                this._img2d = null;
            }
            if (this._effectPlayer1)
            {
                this._rect3d.disposeObj3d(this._effectPlayer1);
                this._effectPlayer1 = null;
            }
            if (this._rect3d)
            {
                Rect3DManager.instance.disposeRect3d(this._rect3d);
                this._rect3d = null;
            }
            super.disposeImpl(param1);
            return;
        }// end function

        private function add2d() : void
        {
            var _loc_1:BitmapData = null;
            if (this.isDisposed)
            {
                return;
            }
            this.add3d();
            if (this._rect3d)
            {
                _loc_1 = this._bg.bitmapData;
                this._img2d = new Img2D(null, _loc_1, new Rectangle(0, 0, 329, 507), false);
                this._rect3d.addImg(this._img2d);
            }
            this.update3DModel();
            return;
        }// end function

        private function update3DModel() : void
        {
            if (this._effectPlayer1)
            {
                this._rect3d.disposeObj3d(this._effectPlayer1);
                this._effectPlayer1 = null;
            }
            var _loc_1:* = PlayerModelConfig.instance.getModelShowById(100010);
            this._effectPlayer1 = EffectPlayerPool.instance.getEffectPlayer(_loc_1.selfEffect, null, this._rect3d.renderList, false);
            this._effectPlayer1.play();
            var _loc_2:int = 1;
            this._effectPlayer1.scaleZ = 1;
            var _loc_2:* = _loc_2;
            this._effectPlayer1.scaleY = _loc_2;
            this._effectPlayer1.scaleX = _loc_2;
            this._rect3d.addObject3d(this._effectPlayer1, 168, 155);
            return;
        }// end function

        private function add3d() : void
        {
            this._rect3d = Rect3DManager.instance.registerWindow(true, new Rectangle(8, 37, 329, 507), this._window);
            Rect3DManager.instance.windowShowHander(null, this._window);
            return;
        }// end function

        private function getGiftListDataProviderByCode(param1:int) : DataProvider
        {
            var _loc_5:Array = null;
            var _loc_6:ItemData = null;
            var _loc_9:YYZiZuanGiftDataGroup = null;
            var _loc_2:* = new DataProvider();
            var _loc_3:* = new ItemData(param1).itemInfo as ItemGiftBagInfo;
            var _loc_4:* = _loc_3.itemList1.split("&");
            var _loc_7:* = _loc_4.length;
            var _loc_8:int = 0;
            while (_loc_8 < _loc_4.length)
            {
                
                _loc_5 = _loc_4[_loc_8].split("#");
                _loc_6 = new ItemData(int(_loc_5[1]));
                _loc_9 = new YYZiZuanGiftDataGroup();
                _loc_9.itemCode = int(_loc_5[1]);
                _loc_9.itemAmount = _loc_5[2];
                _loc_9.isBind = true;
                _loc_2.addItem(_loc_9);
                _loc_8++;
            }
            return _loc_2;
        }// end function

        private function getCopyDataProvider() : DataProvider
        {
            var _loc_1:* = new DataProvider([1, 2, 3]);
            return _loc_1;
        }// end function

    }
}
